#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main() {
    pid_t id = fork();
    if (id == 0) {
      //child
      int count = 5;
      while (count --) { 
        printf("I am child , pid: %d , ppid: %d\n" , getpid() , getppid());
        sleep(1);
      }
      exit(1);
    }

    else if (id > 0) {
      //father
      while (1) {
        printf("I am father , pid: %d , ppid: %d\n" , getpid() , getppid());
        sleep(1);
      }
    }
    /*if (id == 0) { //child
      while (1) {
          printf("I am process: pid: %d , ppid: %d\n" , getpid() , getppid());
          sleep(1);
      }
    }
    else if (id > 0) {//parent
      while (1) {
          printf("I am process: pid: %d , ppid: %d\n" , getpid() , getppid());
          sleep(1);
      }
    }
    else {
      //fork error
    }*/ 
    return 0;
}
